<?php
class LoaiphansController extends AppController {

	var $name = 'Loaiphans';
	var $helpers = array('Html', 'Form');
	var $paginate = array('limit' =>10, 'page' => 1);
	function index() {
		$this->Loaiphan->recursive = 0;
		$this->set('loaiphans', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Loaiphan.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('loaiphan', $this->Loaiphan->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Loaiphan->create();
			if ($this->Loaiphan->save($this->data)) {
				$this->Session->setFlash(__('The Loaiphan has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Loaiphan could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Loaiphan', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Loaiphan->save($this->data)) {
				$this->Session->setFlash(__('The Loaiphan has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Loaiphan could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Loaiphan->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Loaiphan', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Loaiphan->del($id)) {
			$this->Session->setFlash(__('Loaiphan deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}


	function tinh_index() {
		$this->Loaiphan->recursive = 0;
		$this->set('loaiphans', $this->paginate());
	}

	function tinh_view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Loaiphan.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('loaiphan', $this->Loaiphan->read(null, $id));
	}

	function tinh_add() {
		if (!empty($this->data)) {
			$this->Loaiphan->create();
			if ($this->Loaiphan->save($this->data)) {
				$this->Session->setFlash(__('The Loaiphan has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Loaiphan could not be saved. Please, try again.', true));
			}
		}
	}

	function tinh_edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Loaiphan', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Loaiphan->save($this->data)) {
				$this->Session->setFlash(__('The Loaiphan has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Loaiphan could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Loaiphan->read(null, $id);
		}
	}

	function tinh_delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Loaiphan', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Loaiphan->del($id)) {
			$this->Session->setFlash(__('Loaiphan deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>